/*
 * AboutFrame.java
 *
 * Created on 12/12/2011, 21:17:20
 */

package br.mg.bhe.ftpobre.gui.help;

import java.io.File;

/**
 *
 * @author Aureliano
 */
public class AboutFrame extends javax.swing.JDialog {

    /** Creates new form AboutFrame */
    public AboutFrame(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        loadInformation();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        labelTitle = new javax.swing.JLabel();
        labelAbout = new javax.swing.JLabel();
        labelVersion = new javax.swing.JLabel();
        labelVersionInfo = new javax.swing.JLabel();
        labelJava = new javax.swing.JLabel();
        labelJavaInfo = new javax.swing.JLabel();
        labelSystem = new javax.swing.JLabel();
        labelSystemInfo = new javax.swing.JLabel();
        labelHome = new javax.swing.JLabel();
        labelHomeInfo = new javax.swing.JLabel();
        buttonClose = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Sobre");
        setResizable(false);

        labelTitle.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        labelTitle.setText("FTPobre");

        labelAbout.setText("FTPobre é um programa cliente de FTP.");

        labelVersion.setText("Versão:");

        labelVersionInfo.setText("FTPobre 1.0");

        labelJava.setText("Java:");

        labelJavaInfo.setText("...");

        labelSystem.setText("Sistema:");

        labelSystemInfo.setText("...");

        labelHome.setText("Diretório do Sistema:");

        labelHomeInfo.setText("...");

        buttonClose.setText("Fechar");
        buttonClose.setPreferredSize(new java.awt.Dimension(90, 25));
        buttonClose.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonCloseActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(labelAbout)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(labelHome)
                            .addComponent(labelSystem)
                            .addComponent(labelJava)
                            .addComponent(labelVersion))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(labelVersionInfo)
                            .addComponent(labelJavaInfo)
                            .addComponent(labelSystemInfo)
                            .addComponent(labelHomeInfo))))
                .addContainerGap(234, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(188, Short.MAX_VALUE)
                .addComponent(buttonClose, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(155, 155, 155))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(198, Short.MAX_VALUE)
                .addComponent(labelTitle)
                .addGap(184, 184, 184))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(labelTitle)
                .addGap(11, 11, 11)
                .addComponent(labelAbout)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelVersion)
                    .addComponent(labelVersionInfo))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelJava)
                    .addComponent(labelJavaInfo))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelSystem)
                    .addComponent(labelSystemInfo))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelHome)
                    .addComponent(labelHomeInfo))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 19, Short.MAX_VALUE)
                .addComponent(buttonClose, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-449)/2, (screenSize.height-236)/2, 449, 236);
    }// </editor-fold>//GEN-END:initComponents

    private void buttonCloseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCloseActionPerformed
        dispose();
    }//GEN-LAST:event_buttonCloseActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton buttonClose;
    private javax.swing.JLabel labelAbout;
    private javax.swing.JLabel labelHome;
    private javax.swing.JLabel labelHomeInfo;
    private javax.swing.JLabel labelJava;
    private javax.swing.JLabel labelJavaInfo;
    private javax.swing.JLabel labelSystem;
    private javax.swing.JLabel labelSystemInfo;
    private javax.swing.JLabel labelTitle;
    private javax.swing.JLabel labelVersion;
    private javax.swing.JLabel labelVersionInfo;
    // End of variables declaration//GEN-END:variables

    private void loadInformation() {
        String java = System.getProperty("java.vm.name") + " " + System.getProperty("java.version");
        labelJavaInfo.setText(java);
        labelJavaInfo.setToolTipText(java);
        labelSystemInfo.setText(System.getProperty("os.name") + " " + System.getProperty("os.version"));

        String folder = new File("").getAbsolutePath();
        labelHomeInfo.setToolTipText(folder);
        if(folder.length() > 40) {
            labelHomeInfo.setText(folder.substring(0, 37) + "...");
        } else {
            labelHomeInfo.setText(folder);
        }
    }
}